import 'package:flutter/material.dart';
import 'package:flutter_redux/flutter_redux.dart';
import 'package:redux/redux.dart';
import 'package:list_test/homepage.dart';
import 'package:list_test/store/redux_core.dart';
import 'package:list_test/store/actions.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final Store<ReduxState> store = new Store(
    stateReducer,
    initialState: new ReduxState(
      firebaseUser: null,
      mainReference: null,
      entries: new List(),
      hasEntryBeenAdded: false
    ),
    middleware: [firebaseMiddleware].toList()
  );
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    store.dispatch(new InitAction());
    return new StoreProvider<ReduxState> (
      store: store,
      child: new MaterialApp(
        title: 'Flutter Demo',
        theme: ThemeData(
          primarySwatch: Colors.blue,
        ),
        home: HomePage(title: 'WEIGHT TRACKER'),
      ),
    );
  }
}
